package com.glory.dmegcpda.viewmodel

import android.util.Log
import com.glory.dmegcpda.base.Constant
import com.glory.dmegcpda.model.LoginRepository
import com.glory.dmegcpda.utils.TrimUtils
import com.glory.mvvmnet.base.BaseViewModel
import com.google.gson.JsonObject
import java.io.UnsupportedEncodingException

class LoginViewModel : BaseViewModel() {

    private val saleChanceRankRepository by lazy{LoginRepository()}

    fun initData(user: String, password: String) {
        val bodyMap = JsonObject()
        bodyMap.addProperty("USERNAME", user)
        bodyMap.addProperty("PASSWORD", password)
        bodyMap.addProperty("ACTIONTYPE", "LOGIN")
        Constant.userName = user
//        defUI.callObserve.call()
        launchOnlyResult({
            val login = saleChanceRankRepository.login(bodyMap)
            Constant.orgName = login.uSER.oRGNAME
            Constant.orgrrn = login.uSER.dEFAULTORGRRN
            defUI.callObserve.call()
        })
    }

}